﻿using HKB.Common;
using HKB.Web;
using HKB.Web.Admin;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
public partial class Admin_Admin_ShopModule : Admin, IRequiresSessionState
{
    private Shop_Module _module = null;
    protected Shop_Module module
    {
        get
        {
            Shop_Module module;
            if (this._module == null)
            {
                this._module = new Shop_Module(this.conn);
                module = this._module;
            }
            else
            {
                module = this._module;
            }
            return module;
        }
    }
    protected DefaultProfile profile
    {
        get
        {
            return (DefaultProfile)this.Context.Profile;
        }
    }
    protected global_asax applicationInstance
    {
        get
        {
            return (global_asax)this.Context.ApplicationInstance;
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!base.admin.CheckAdminPower(10))
        {
            base.WriteLog("View", Language.GetAdminMsg("Log/Access", "0"), "ArticleModule");
            base.WriteRightErrMsg();
        }
        if (Fetch.Get("Action") == "Modify")
        {
            this.FormView1.DefaultMode = FormViewMode.Edit;
        }
        if (!base.IsPostBack)
        {
            this.FormView1.DataSource = this.module.GetModuleById(Fetch.GetID("id"));
            this.FormView1.DataBind();
        }
    }
    public string JustStatusNull(string StrID)
    {
        string result = "";
        DataSet dataSet = this.conn.GetDataSet("select * from HLShop_Module where id=" + int.Parse(StrID));
        if (dataSet != null && dataSet.Tables[0].Rows.Count > 0)
        {
            if (dataSet.Tables[0].Rows[0]["Status"] != null)
            {
                result = dataSet.Tables[0].Rows[0]["Status"].ToString();
            }
        }
        else
        {
            result = "1";
        }
        return result;
    }
    protected void AddModule(object sender, CommandEventArgs e)
    {
        TextBox textBox = (TextBox)this.FormView1.FindControl("name");
        TextBox textBox2 = (TextBox)this.FormView1.FindControl("Title");
        RadioButtonList radioButtonList = (RadioButtonList)this.FormView1.FindControl("Status");
        if (this.module.GetModuleByName(textBox.Text).Rows.Count > 0)
        {
            this.WriteSuccessMsg("", "名称已存在！", "");
        }
        this.module.AddModule(0, "", "", "", "", "", textBox.Text, 0, 0, 0, "", textBox2.Text, "", Convert.ToInt32(radioButtonList.SelectedValue.ToString()));
        this.WriteSuccessMsg("", Language.GetAdminMsg("Common/AddSuccess"), "Admin_ShopManageModule.aspx");
    }
    protected void EditModule(object sender, CommandEventArgs e)
    {
        TextBox textBox = (TextBox)this.FormView1.FindControl("name");
        TextBox textBox2 = (TextBox)this.FormView1.FindControl("Title");
        RadioButtonList radioButtonList = (RadioButtonList)this.FormView1.FindControl("Status");
        this.module.UpdateModule("", "", "", "", "", textBox.Text, 0, 0, 0, "", textBox2.Text, "", Convert.ToInt32(radioButtonList.SelectedValue.ToString()), Fetch.GetID("id"));
        this.WriteSuccessMsg("", Language.GetAdminMsg("Common/EditSuccess"), "Admin_ShopManageModule.aspx");
    }
}
